package com.lims.数据库;


import com.lims.utils.DbUtil;

import java.util.List;
import java.util.Map;

/**
 * @author limaosheng
 * @create 2022-05-10 11:23
 * @desc
 */
public class 数据库查询 {
    /**
     * 查询单个库所有表
     */
    public static final String SQL = "select TABLE_NAME as tableName,TABLE_COMMENT as tableComment from information_schema.`TABLES` where TABLE_SCHEMA = 'param'";
    public static List<Map<String,Object>> getAllTables(String dbName){
        List<Map<String,Object>> tables = DbUtil.getList(SQL.replace("param",dbName),DbUtil.getConn());
        return tables;
    }

    /**
     * 查询单个表结构
     */
    public static final String COL_SQL = "select column_name,column_comment,is_nullable,column_type,data_type,character_maximum_length,column_key from information_schema.columns where table_name= 'tableName' and table_schema = 'dbName'";
    public static List<Map<String,Object>> getConlumn(String dbName,String tableName){
        List<Map<String,Object>> tables = DbUtil.getList(COL_SQL.replace("dbName",dbName).replace("tableName",tableName),DbUtil.getConn());
        return tables;
    }
}
